<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:include="include :: header('新增数据源')"/>
</head>
<body>
<form class="layui-form">
    <div class="mainBox">
        <div class="main-container">

        <div class="layui-form-item">
            <label class="layui-form-label">数据源名称：</label>
            <div class="layui-input-block">
                <input type="text" name="name" placeholder="请输入数据源名称"
                    class="layui-input" />
            </div>
        </div>
            <div class="layui-form-item">
                <label class="layui-form-label">链接：</label>
                <div class="layui-input-block">
                    <input type="text" name="url" placeholder="请输入链接"
                           class="layui-input" />
                </div>
            </div>
        <div class="layui-form-item">
            <label class="layui-form-label">用户名：</label>
            <div class="layui-input-block">
                <input type="text" name="username" placeholder="请输入用户名"
                    class="layui-input" />
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">密码：</label>
            <div class="layui-input-block">
                <input type="password" name="password" placeholder="请输入密码"
                    class="layui-input" />
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">驱动：</label>
            <div class="layui-input-block">
                <input type="text" name="driver" placeholder="请输入驱动" value="com.mysql.cj.jdbc.Driver"
                    class="layui-input" />
            </div>
        </div>

            <div class="layui-form-item">
                <label class="layui-form-label">是否启用：</label>
                <div class="layui-input-block">
                    <div class="radio-box">
                        <input type="radio" checked name="enable" value="1" title="启用" >
                        <input type="radio" name="enable" value="0" title="未启用" >
                    </div>
                </div>
            </div>

        </div>
    </div>
    <div class="bottom">
        <div class="button-container">
            <button type="submit" class="pear-btn pear-btn-primary pear-btn-sm" lay-submit="" lay-filter="dataSource-save">
                <i class="layui-icon layui-icon-ok"></i>
                提交
            </button>
            <button type="reset" class="pear-btn pear-btn-sm">
                <i class="layui-icon layui-icon-refresh"></i>
                重置
            </button>
        </div>
    </div>
</form>
</body>
<th:block th:include="include :: footer"/>
<script th:inline="javascript">

    layui.use(['form', 'jquery', 'laydate', 'dictionary','gray'], function () {
        let form = layui.form;
        let $ = layui.jquery;
        let laydate = layui.laydate;
        let Gray = layui.gray;

        let prefix = "/ipaas/dataSource/"


        form.on('submit(dataSource-save)', function (data) {
            Gray.post(prefix + 'save',data.field,function (result){
                layer.msg(result.msg, {icon: 1, time: 1000}, function () {
                    parent.layer.close(parent.layer.getFrameIndex(window.name));
                    parent.layui.table.reload("dataSource-table");
                });
            });

            return false;
        });
    });
</script>
</html>